home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBGRX100.ARJ / BYTEDRAW.H < prev    next >
Text File  |  1992-04-10  |  17KB  |  463 lines

  1. /** 
  2.  ** BYTEDRAW.H 
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #ifndef _BYTEDRAW_H_
  25. #define _BYTEDRAW_H_
  26.  
  27. #ifdef  __TURBOC__
  28. #pragma inline
  29. #endif
  30.  
  31. /*
  32.  * utilities -- other files may define them too
  33.  */
  34. #ifndef _SaveDS
  35.  
  36. #ifdef  __TURBOC__
  37. #define _ClrDir()    asm cld
  38. #define _SetDir()    asm std
  39. #define _SaveDS()    asm push    ds
  40. #define _RestoreDS()    asm pop        ds
  41. #endif
  42.  
  43. #ifdef  __GNUC__
  44. #define _ASV        asm volatile
  45. #define _ClrDir()    _ASV("cld")
  46. #define _SetDir()    _ASV("std")
  47. #define _SaveDS()
  48. #define _RestoreDS()
  49. #endif
  50.  
  51. #endif  /* _SaveDS */
  52.  
  53. #ifdef  __TURBOC__
  54. /*
  55.  * display a bit mapped font character (both FGC and BGC)
  56.  */
  57. #define __WRTFONT__(dst,offs,fontbits,wdt,hgt,colors,putbyte) do {    \
  58.     _BX = hgt;                                \
  59.     _DX = colors;                            \
  60.     asm les    di,DWORD PTR dst;                    \
  61.     asm lds    si,DWORD PTR fontbits;                    \
  62.   Font##putbyte##NextRow:                        \
  63.     asm mov    cx,WORD PTR wdt;                    \
  64.   Font##putbyte##ReadBits:                        \
  65.     asm lodsb;                                \
  66.     asm mov    ah,al;                            \
  67.     asm stc;                                \
  68.     asm adc    ah,ah;                            \
  69.   Font##putbyte##Loop:                            \
  70.     asm sbb    al,al;                            \
  71.     asm and    al,dh;                            \
  72.     asm xor    al,dl;                            \
  73.     putbyte;                                \
  74.     asm add    ah,ah;                            \
  75.     asm loopnz  Font##putbyte##Loop;                    \
  76.     asm or    cx,cx;                            \
  77.     asm jnz    Font##putbyte##ReadBits;                \
  78.     asm add    di,WORD PTR offs;                    \
  79.     asm dec    bx;                            \
  80.     asm jnz    Font##putbyte##NextRow;                    \
  81. } while(0)
  82.  
  83. /*
  84.  * display a bit mapped font character (FGC or BGC only)
  85.  */
  86. #define __WR1CFNT__(dst,offs,fontbits,wdt,hgt,color,jump,opr) do {    \
  87.     _BX = hgt;                                \
  88.     _DL = color;                            \
  89.     asm les    di,DWORD PTR dst;                    \
  90.     asm lds    si,DWORD PTR fontbits;                    \
  91.   Font##jump##opr##NextRow:                        \
  92.     asm mov    cx,WORD PTR wdt;                    \
  93.   Font##jump##opr##ReadBits:                        \
  94.     asm lodsb;                                \
  95.     asm stc;                                \
  96.     asm adc    al,al;                            \
  97.   Font##jump##opr##Loop:                        \
  98.     asm jump    Font##jump##opr##NoSet;                    \
  99.     asm opr    BYTE PTR es:[di],dl;                    \
  100.   Font##jump##opr##NoSet:                        \
  101.     asm inc    di;                            \
  102.     asm add    al,al;                            \
  103.     asm loopnz  Font##jump##opr##Loop;                    \
  104.     asm or    cx,cx;                            \
  105.     asm jnz    Font##jump##opr##ReadBits;                \
  106.     asm add    di,WORD PTR offs;                    \
  107.     asm dec    bx;                            \
  108.     asm jnz    Font##jump##opr##NextRow;                \
  109. } while(0)
  110.  
  111. #define __WFSET__    asm stosb
  112. #define __WFXOR__    asm xor      BYTE PTR es:[di],al; asm inc     di
  113. #define __WFOR__    asm or      BYTE PTR es:[di],al; asm inc     di
  114. #define __WFAND__    asm and      BYTE PTR es:[di],al; asm inc     di
  115.  
  116. #define _WriteFont(dp,o,bp,w,h,cls)    __WRTFONT__(dp,o,bp,w,h,cls,__WFSET__)
  117. #define _WriteFontXor(dp,o,bp,w,h,cls)  __WRTFONT__(dp,o,bp,w,h,cls,__WFXOR__)
  118. #define _WriteFontOr(dp,o,bp,w,h,cls)    __WRTFONT__(dp,o,bp,w,h,cls,__WFOR__)
  119. #define _WriteFontAnd(dp,o,bp,w,h,cls)  __WRTFONT__(dp,o,bp,w,h,cls,__WFAND__)
  120.  
  121. #define _WrFGCFont(dp,o,bp,w,h,fg)    __WR1CFNT__(dp,o,bp,w,h,fg,jnc,mov)
  122. #define _WrFGCFontXor(dp,o,bp,w,h,fg)    __WR1CFNT__(dp,o,bp,w,h,fg,jnc,xor)
  123. #define _WrFGCFontOr(dp,o,bp,w,h,fg)    __WR1CFNT__(dp,o,bp,w,h,fg,jnc,or)
  124. #define _WrFGCFontAnd(dp,o,bp,w,h,fg)    __WR1CFNT__(dp,o,bp,w,h,fg,jnc,and)
  125.  
  126. #define _WrBGCFont(dp,o,bp,w,h,bg)    __WR1CFNT__(dp,o,bp,w,h,bg,jc,mov)
  127. #define _WrBGCFontXor(dp,o,bp,w,h,bg)    __WR1CFNT__(dp,o,bp,w,h,bg,jc,xor)
  128. #define _WrBGCFontOr(dp,o,bp,w,h,bg)    __WR1CFNT__(dp,o,bp,w,h,bg,jc,or)
  129. #define _WrBGCFontAnd(dp,o,bp,w,h,bg)    __WR1CFNT__(dp,o,bp,w,h,bg,jc,and)
  130.  
  131. /*
  132.  * set a bitmap patterned row
  133.  */
  134. #define __PTNROW__(dst,maskpatt,width,colors,putbyte) do {        \
  135.     _DX = maskpatt;                            \
  136.     _CX = width;                            \
  137.     _BX = colors;                            \
  138.     asm les    di,DWORD PTR dst;                    \
  139.     asm sub    bl,bh;                            \
  140.   Patt##putbyte##Loop:                            \
  141.     asm rol    dl,1;                            \
  142.     asm sbb    al,al;                            \
  143.     asm and    al,bh;                            \
  144.     asm xor    al,bl;                            \
  145.     putbyte;                                \
  146.     asm loop    Patt##putbyte##Loop;                    \
  147. } while(0)
  148.  
  149. /*
  150.  * set a bitmap patterned row, foreground only
  151.  */
  152. #define __P1CROW__(dst,maskpatt,width,color,jump,opr) do {        \
  153.     _DX = maskpatt;                            \
  154.     _CX = width;                            \
  155.     _AX = color;                            \
  156.     asm les    di,DWORD PTR dst;                    \
  157.   Patt##jump##opr##Loop:                        \
  158.     asm rol    dl,1;                            \
  159.     asm jump    Patt##jump##opr##NoSet;                    \
  160.     asm opr    BYTE PTR es:[di],al;                    \
  161.   Patt##jump##opr##NoSet:                        \
  162.     asm inc    di;                            \
  163.     asm loop    Patt##jump##opr##Loop;                    \
  164. } while(0)
  165.  
  166. #define _PatternSet(dst,msk,wdt,cls)    __PTNROW__(dst,msk,wdt,cls,__WFSET__)
  167. #define _PatternXor(dst,msk,wdt,cls)    __PTNROW__(dst,msk,wdt,cls,__WFXOR__)
  168. #define _PatternOr(dst,msk,wdt,cls)    __PTNROW__(dst,msk,wdt,cls,__WFOR__)
  169. #define _PatternAnd(dst,msk,wdt,cls)    __PTNROW__(dst,msk,wdt,cls,__WFAND__)
  170.  
  171. #define _PattFGCSet(dst,msk,wdt,fg)    __P1CROW__(dst,msk,wdt,fg,jnc,mov)
  172. #define _PattFGCXor(dst,msk,wdt,fg)    __P1CROW__(dst,msk,wdt,fg,jnc,xor)
  173. #define _PattFGCOr(dst,msk,wdt,fg)    __P1CROW__(dst,msk,wdt,fg,jnc,or)
  174. #define _PattFGCAnd(dst,msk,wdt,fg)    __P1CROW__(dst,msk,wdt,fg,jnc,and)
  175.  
  176. #define _PattBGCSet(dst,msk,wdt,bg)    __P1CROW__(dst,msk,wdt,bg,jc,mov)
  177. #define _PattBGCXor(dst,msk,wdt,bg)    __P1CROW__(dst,msk,wdt,bg,jc,xor)
  178. #define _PattBGCOr(dst,msk,wdt,bg)    __P1CROW__(dst,msk,wdt,bg,jc,or)
  179. #define _PattBGCAnd(dst,msk,wdt,bg)    __P1CROW__(dst,msk,wdt,bg,jc,and)
  180.  
  181. /*
  182.  * X major line drawing
  183.  */
  184. #define __XLINE__(dst,offs,deltx,delty,color,putbyte) do {        \
  185.     _CX = deltx;                            \
  186.     _BX = delty;                            \
  187.     _AX = color;                            \
  188.     _SI = offs;                                \
  189.     asm les    di,dst;                            \
  190.     asm mov    dx,cx;                            \
  191.     asm shr    dx,1;                            \
  192.     asm inc    cx;                            \
  193.   LineX##putbyte##Loop:                            \
  194.     putbyte;                                \
  195.     asm sub    dx,bx;                            \
  196.     asm jnc    LineX##putbyte##NoAdjust;                \
  197.     asm add    dx,WORD PTR deltx;                    \
  198.     asm add    di,si;                            \
  199.   LineX##putbyte##NoAdjust:                        \
  200.     asm loop    LineX##putbyte##Loop;                    \
  201. } while(0)
  202.  
  203. #define __XLSET__    asm stosb
  204. #define __XLXOR__    asm xor      BYTE PTR es:[di],al; asm inc     di
  205. #define __XLOR__    asm or      BYTE PTR es:[di],al; asm inc     di
  206. #define __XLAND__    asm and      BYTE PTR es:[di],al; asm inc     di
  207.  
  208. #define _DrawXLine(dp,do,dx,dy,c)    __XLINE__(dp,do,dx,dy,c,__XLSET__)
  209. #define _DrawXLineXor(dp,do,dx,dy,c)    __XLINE__(dp,do,dx,dy,c,__XLXOR__)
  210. #define _DrawXLineOr(dp,do,dx,dy,c)    __XLINE__(dp,do,dx,dy,c,__XLOR__)
  211. #define _DrawXLineAnd(dp,do,dx,dy,c)    __XLINE__(dp,do,dx,dy,c,__XLAND__)
  212.  
  213. /*
  214.  * Y major line drawing
  215.  */
  216. #define __YLINE__(dst,offs,deltx,delty,color,putbyte) do {        \
  217.     _CX = delty;                            \
  218.     _BX = deltx;                            \
  219.     _AX = color;                            \
  220.     _SI = offs;                                \
  221.     asm les    di,dst;                            \
  222.     asm mov    dx,cx;                            \
  223.     asm shr    dx,1;                            \
  224.     asm inc    cx;                            \
  225.   LineY##putbyte##Loop:                            \
  226.     putbyte;                                \
  227.     asm add    di,si;                            \
  228.     asm sub    dx,bx;                            \
  229.     asm jnc    LineY##putbyte##NoAdjust;                \
  230.     asm add    dx,WORD PTR delty;                    \
  231.     asm inc    di;                            \
  232.   LineY##putbyte##NoAdjust:                        \
  233.     asm loop    LineY##putbyte##Loop;                    \
  234. } while(0)
  235.  
  236. #define __YLSET__    asm mov      BYTE PTR es:[di],al
  237. #define __YLXOR__    asm xor      BYTE PTR es:[di],al
  238. #define __YLOR__    asm or      BYTE PTR es:[di],al
  239. #define __YLAND__    asm and      BYTE PTR es:[di],al
  240.  
  241. #define _DrawYLine(dp,do,dx,dy,c)    __YLINE__(dp,do,dx,dy,c,__YLSET__)
  242. #define _DrawYLineXor(dp,do,dx,dy,c)    __YLINE__(dp,do,dx,dy,c,__YLXOR__)
  243. #define _DrawYLineOr(dp,do,dx,dy,c)    __YLINE__(dp,do,dx,dy,c,__YLOR__)
  244. #define _DrawYLineAnd(dp,do,dx,dy,c)    __YLINE__(dp,do,dx,dy,c,__YLAND__)
  245. #endif  /* __TURBOC__ */
  246.  
  247. #ifdef  __GNUC__
  248. /*
  249.  * display a bit mapped font character (both FGC and BGC)
  250.  */
  251. #define __WRTFONT__(dst,offs,bits,wdt,hgt,colors,putbyte) _ASV("      \n\
  252.     movl    %0,%%edi                          \n\
  253.     movl    %2,%%esi                          \n\
  254.     movl    %4,%%ebx                          \n\
  255.     movl    %5,%%edx                          \n\
  256. L_Font"#putbyte"NextRow:                          \n\
  257.     movl    %3,%%ecx                          \n\
  258. L_Font"#putbyte"ReadBits:                          \n\
  259.     lodsb                                  \n\
  260.     movb    %%al,%%ah                          \n\
  261.     stc                                  \n\
  262.     adcb    %%ah,%%ah                          \n\
  263. L_Font"#putbyte"Loop:                              \n\
  264.     sbbb    %%al,%%al                          \n\
  265.     andb    %%dh,%%al                          \n\
  266.     xorb    %%dl,%%al                          \n\
  267.     "putbyte"                              \n\
  268.     addb    %%ah,%%ah                          \n\
  269.     loopnz  L_Font"#putbyte"Loop                      \n\
  270.     orl    %%ecx,%%ecx                          \n\
  271.     jnz    L_Font"#putbyte"ReadBits                  \n\
  272.     addl    %1,%%edi                          \n\
  273.     decl    %%ebx                              \n\
  274.     jnz    L_Font"#putbyte"NextRow                       "\
  275.     : /* NOTHING */                            \
  276.     : "g" (dst), "g" (offs), "g" (bits),                \
  277.       "g" (wdt), "g" (hgt),  "g" (colors)                \
  278.     : "di", "si", "dx", "cx", "bx", "ax"                \
  279. )
  280.  
  281. /*
  282.  * display a bit mapped font character (FGC or BGC only)
  283.  */
  284. #define __WR1CFNT__(dst,offs,bits,wdt,hgt,color,jump,opr)     _ASV("  \n\
  285.     movl    %0,%%edi                          \n\
  286.     movl    %2,%%esi                          \n\
  287.     movl    %4,%%ebx                          \n\
  288.     movl    %5,%%edx                          \n\
  289. L_Font"jump opr"NextRow:                          \n\
  290.     movl    %3,%%ecx                          \n\
  291. L_Font"jump opr"ReadBits:                          \n\
  292.     lodsb                                  \n\
  293.     stc                                  \n\
  294.     adcb    %%al,%%al                          \n\
  295. L_Font"jump opr"Loop:                              \n\
  296.     "jump"  L_Font"jump opr"NoSet                      \n\
  297.     "opr"b  %%dl,(%%edi)                          \n\
  298. L_Font"jump opr"NoSet:                              \n\
  299.     incl    %%edi                              \n\
  300.     addb    %%al,%%al                          \n\
  301.     loopnz  L_Font"jump opr"Loop                      \n\
  302.     orl    %%ecx,%%ecx                          \n\
  303.     jnz    L_Font"jump opr"ReadBits                  \n\
  304.     addl    %1,%%edi                          \n\
  305.     decl    %%ebx                              \n\
  306.     jnz    L_Font"jump opr"NextRow                       "\
  307.     : /* NOTHING */                            \
  308.     : "g" (dst), "g" (offs), "g" (bits),                \
  309.       "g" (wdt), "g" (hgt),  "g" (color)                \
  310.     : "di", "si", "dx", "cx", "bx", "ax"                \
  311. )
  312.  
  313. #define __WFSET__    "stosb"
  314. #define __WFXOR__    "xorb   %%al,(%%edi); incl  %%edi"
  315. #define __WFOR__    "orb    %%al,(%%edi); incl  %%edi"
  316. #define __WFAND__    "andb   %%al,(%%edi); incl  %%edi"
  317.  
  318. #define _WriteFont(dp,o,bp,w,h,cls)    __WRTFONT__(dp,o,bp,w,h,cls,__WFSET__)
  319. #define _WriteFontXor(dp,o,bp,w,h,cls)  __WRTFONT__(dp,o,bp,w,h,cls,__WFXOR__)
  320. #define _WriteFontOr(dp,o,bp,w,h,cls)    __WRTFONT__(dp,o,bp,w,h,cls,__WFOR__)
  321. #define _WriteFontAnd(dp,o,bp,w,h,cls)  __WRTFONT__(dp,o,bp,w,h,cls,__WFAND__)
  322.  
  323. #define _WrFGCFont(dp,o,bp,w,h,fg)    __WR1CFNT__(dp,o,bp,w,h,fg,"jnc","mov")
  324. #define _WrFGCFontXor(dp,o,bp,w,h,fg)    __WR1CFNT__(dp,o,bp,w,h,fg,"jnc","xor")
  325. #define _WrFGCFontOr(dp,o,bp,w,h,fg)    __WR1CFNT__(dp,o,bp,w,h,fg,"jnc","or")
  326. #define _WrFGCFontAnd(dp,o,bp,w,h,fg)    __WR1CFNT__(dp,o,bp,w,h,fg,"jnc","and")
  327.  
  328. #define _WrBGCFont(dp,o,bp,w,h,bg)    __WR1CFNT__(dp,o,bp,w,h,bg,"jc","mov")
  329. #define _WrBGCFontXor(dp,o,bp,w,h,bg)    __WR1CFNT__(dp,o,bp,w,h,bg,"jc","xor")
  330. #define _WrBGCFontOr(dp,o,bp,w,h,bg)    __WR1CFNT__(dp,o,bp,w,h,bg,"jc","or")
  331. #define _WrBGCFontAnd(dp,o,bp,w,h,bg)    __WR1CFNT__(dp,o,bp,w,h,bg,"jc","and")
  332.  
  333. /*
  334.  * set a bitmap patterned row
  335.  */
  336. #define __PTNROW__(dst,maskpatt,width,colors,putbyte) _ASV("          \n\
  337.     movl    %0,%%edi                          \n\
  338.     movl    %1,%%edx                          \n\
  339.     movl    %2,%%ecx                          \n\
  340.     movl    %3,%%ebx                          \n\
  341. L_Patt"#putbyte"Loop:                              \n\
  342.     rolb    $1,%%dl                              \n\
  343.     sbbb    %%al,%%al                          \n\
  344.     andb    %%bh,%%al                          \n\
  345.     xorb    %%bl,%%al                          \n\
  346.     "putbyte"                              \n\
  347.     loop    L_Patt"#putbyte"Loop                       "\
  348.     : /* NOTHING */                            \
  349.     : "g" (dst), "g" (maskpatt), "g" (width), "g" (colors)        \
  350.     : "di", "dx", "cx", "bx", "ax"                    \
  351. )
  352.  
  353. /*
  354.  * set a bitmap patterned row, foreground or background only
  355.  */
  356. #define __P1CROW__(dst,maskpatt,width,color,jump,opr) _ASV("          \n\
  357.     movl    %0,%%edi                          \n\
  358.     movl    %1,%%edx                          \n\
  359.     movl    %2,%%ecx                          \n\
  360.     movl    %3,%%eax                          \n\
  361. L_Patt"jump opr"Loop:                              \n\
  362.     rolb    $1,%%dl                              \n\
  363.     "jump"  L_Patt"jump opr"NoSet                      \n\
  364.     "opr"b  %%al,(%%edi)                          \n\
  365. L_Patt"jump opr"NoSet:                              \n\
  366.     incl    %%edi                              \n\
  367.     loop    L_Patt"jump opr"Loop                      \n\
  368. L_Patt"jump opr"End:                               "\
  369.     : /* NOTHING */                            \
  370.     : "g" (dst), "g" (maskpatt), "g" (width), "g" (color)        \
  371.     : "di", "dx", "cx", "ax"                    \
  372. )
  373.  
  374. #define _PatternSet(dst,msk,wdt,cls)    __PTNROW__(dst,msk,wdt,cls,__WFSET__)
  375. #define _PatternXor(dst,msk,wdt,cls)    __PTNROW__(dst,msk,wdt,cls,__WFXOR__)
  376. #define _PatternOr(dst,msk,wdt,cls)    __PTNROW__(dst,msk,wdt,cls,__WFOR__)
  377. #define _PatternAnd(dst,msk,wdt,cls)    __PTNROW__(dst,msk,wdt,cls,__WFAND__)
  378.  
  379. #define _PattFGCSet(dst,msk,wdt,fg)    __P1CROW__(dst,msk,wdt,fg,"jnc","mov")
  380. #define _PattFGCXor(dst,msk,wdt,fg)    __P1CROW__(dst,msk,wdt,fg,"jnc","xor")
  381. #define _PattFGCOr(dst,msk,wdt,fg)    __P1CROW__(dst,msk,wdt,fg,"jnc","or")
  382. #define _PattFGCAnd(dst,msk,wdt,fg)    __P1CROW__(dst,msk,wdt,fg,"jnc","and")
  383.  
  384. #define _PattBGCSet(dst,msk,wdt,bg)    __P1CROW__(dst,msk,wdt,bg,"jc","mov")
  385. #define _PattBGCXor(dst,msk,wdt,bg)    __P1CROW__(dst,msk,wdt,bg,"jc","xor")
  386. #define _PattBGCOr(dst,msk,wdt,bg)    __P1CROW__(dst,msk,wdt,bg,"jc","or")
  387. #define _PattBGCAnd(dst,msk,wdt,bg)    __P1CROW__(dst,msk,wdt,bg,"jc","and")
  388.  
  389. /*
  390.  * X major line drawing
  391.  */
  392. #define __XLINE__(dst,offs,deltx,delty,color,putbyte) _ASV("          \n\
  393.     movl    %0,%%edi                          \n\
  394.     movl    %1,%%esi                          \n\
  395.     movl    %2,%%ecx                          \n\
  396.     movl    %3,%%ebx                          \n\
  397.     movl    %4,%%eax                          \n\
  398.     movl    %%ecx,%%edx                          \n\
  399.     shrl    $1,%%edx                          \n\
  400.     incl    %%ecx                              \n\
  401. L_LineX"#putbyte"Loop:                              \n\
  402.     "putbyte"                              \n\
  403.     subl    %%ebx,%%edx                          \n\
  404.     jnc    L_LineX"#putbyte"NoAdjust                  \n\
  405.     addl    %2,%%edx                          \n\
  406.     addl    %%esi,%%edi                          \n\
  407. L_LineX"#putbyte"NoAdjust:                          \n\
  408.     loop    L_LineX"#putbyte"Loop                       "\
  409.     : /* NOTHING */                            \
  410.     : "g" (dst), "g" (offs), "g" (deltx), "g" (delty), "g" (color)  \
  411.     : "di", "si", "dx", "cx", "bx", "ax"                \
  412. )
  413.  
  414. #define __XLSET__    "stosb"
  415. #define __XLXOR__    "xorb   %%al,(%%edi); incl  %%edi"
  416. #define __XLOR__    "orb    %%al,(%%edi); incl  %%edi"
  417. #define __XLAND__    "andb   %%al,(%%edi); incl  %%edi"
  418.  
  419. #define _DrawXLine(dp,do,dx,dy,c)    __XLINE__(dp,do,dx,dy,c,__XLSET__)
  420. #define _DrawXLineXor(dp,do,dx,dy,c)    __XLINE__(dp,do,dx,dy,c,__XLXOR__)
  421. #define _DrawXLineOr(dp,do,dx,dy,c)    __XLINE__(dp,do,dx,dy,c,__XLOR__)
  422. #define _DrawXLineAnd(dp,do,dx,dy,c)    __XLINE__(dp,do,dx,dy,c,__XLAND__)
  423.  
  424. /*
  425.  * Y major line drawing
  426.  */
  427. #define __YLINE__(dst,offs,deltx,delty,color,putbyte) _ASV("          \n\
  428.     movl    %0,%%edi                          \n\
  429.     movl    %1,%%esi                          \n\
  430.     movl    %3,%%ecx                          \n\
  431.     movl    %2,%%ebx                          \n\
  432.     movl    %4,%%eax                          \n\
  433.     movl    %%ecx,%%edx                          \n\
  434.     shrl    $1,%%edx                          \n\
  435.     incl    %%ecx                              \n\
  436. L_LineY"#putbyte"Loop:                              \n\
  437.     "putbyte"                              \n\
  438.     addl    %%esi,%%edi                          \n\
  439.     subl    %%ebx,%%edx                          \n\
  440.     jnc    L_LineY"#putbyte"NoAdjust                  \n\
  441.     addl    %3,%%edx                          \n\
  442.     incl    %%edi                              \n\
  443. L_LineY"#putbyte"NoAdjust:                          \n\
  444.     loop    L_LineY"#putbyte"Loop                       "\
  445.     : /* NOTHING */                            \
  446.     : "g" (dst), "g" (offs), "g" (deltx), "g" (delty), "g" (color)  \
  447.     : "di", "si", "dx", "cx", "bx", "ax"                \
  448. )
  449.  
  450. #define __YLSET__    "movb   %%al,(%%edi)"
  451. #define __YLXOR__    "xorb   %%al,(%%edi)"
  452. #define __YLOR__    "orb    %%al,(%%edi)"
  453. #define __YLAND__    "andb   %%al,(%%edi)"
  454.  
  455. #define _DrawYLine(dp,do,dx,dy,c)    __YLINE__(dp,do,dx,dy,c,__YLSET__)
  456. #define _DrawYLineXor(dp,do,dx,dy,c)    __YLINE__(dp,do,dx,dy,c,__YLXOR__)
  457. #define _DrawYLineOr(dp,do,dx,dy,c)    __YLINE__(dp,do,dx,dy,c,__YLOR__)
  458. #define _DrawYLineAnd(dp,do,dx,dy,c)    __YLINE__(dp,do,dx,dy,c,__YLAND__)
  459. #endif  /* __GNUC__ */
  460.  
  461. #endif  /* whole file */
  462.  
  463.